package com.engine4cloud.tdf.admin.controller;

import com.engine4cloud.tdf.admin.api.dto.UserRoleResultDTO;
import com.engine4cloud.tdf.admin.service.SysUserRoleService;
import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户角色
 *
 * @author wenjie
 * @date 2024-04-22 22:40:06
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/sysUserRole")
@Tag(description = "sysUserRole", name = "用户角色")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysUserRoleController {

    private final SysUserRoleService userRoleService;

    /**
     * 获取角色
     *
     * @param userId 用户id
     * @return R<?>
     */
    @Inner
    @Operation(summary = "获取角色", description = "获取角色")
    @GetMapping("/list/{userId}")
    public R<List<UserRoleResultDTO>> listByUserId(@PathVariable Long userId) {
        return R.ok(userRoleService.listByUserId(userId));
    }
}
